import { Injectable } from '@angular/core';
import {Observable} from "rxjs/index";
import {HttpClient} from "@angular/common/http";
import {ConfigService} from "./config.service";

@Injectable({
  providedIn: 'root'
})
export class ConfigurationService {


    constructor(private http: HttpClient, private configService: ConfigService) {
    }

    getOne(id: string): Observable<any> {
        //let headers = this.authService.getHeader();
        //let options = {headers: headers};
        return this.http.get((this.configService.api.url) + '/configurations' + "/detail/" + id);
    }

    create(configuration: any): Observable<any> {
        //let headers = this.authService.getHeader();
        //let options = {headers: headers};
        return this.http.post((this.configService.api.url) + '/configurations' + "/create", {configuration: configuration});
    }

    createMany(configurations: any): Observable<any> {
        //let headers = this.authService.getHeader();
        //let options = {headers: headers};
        return this.http.post((this.configService.api.url) + '/configurations' + "/create/many", {configurations: configurations});
    }

    update(configuration: any): Observable<any> {
        //let headers = this.authService.getHeader();
        //let options = {headers: headers};
        return this.http.post((this.configService.api.url) + '/configurations' + "/update", {configuration: configuration});
    }

    delete(configuration: any): Observable<any> {
        //let headers = this.authService.getHeader();
        //let options = {headers: headers};
        return this.http.post((this.configService.api.url) + '/configurations' + "/remove", {configuration: configuration});
    }
}
